//
//  AppDelegate.swift
//  loveHHEveryDay
//
//  Created by yw on 2025/4/2.
//

import UIKit
import SwiftUI

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?
    

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        window = UIWindow(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height))
        window?.makeKeyAndVisible()
//        let hostVC = UIHostingController(rootView: TabBarView())
        if let isLogin = UserDefaults.standard.value(forKey: kUserDateLogin) as? Bool {
            if isLogin {
                let tabBarView = UIHostingController(rootView: TabBarView())
//                let testVc = TestViewController()
                window?.rootViewController = tabBarView
            } else {
                let hostVC = UIHostingController(rootView: WelcomeView())
                window?.rootViewController = hostVC
            }
        } else {
            let hostVC = UIHostingController(rootView: WelcomeView())
            window?.rootViewController = hostVC
        }
        return true
    }




}


extension UIApplication {
    func endEditing() {
        sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
    }
}

